package com.mjp.learn.multi.basic;

/**
 * join 方法 等待调用这个方法的线程结束
 * t.join()方法阻塞调用此方法的线程(calling thread)进入 TIMED_WAITING 状态，直到线程t完成，此线程再继续
 * 底层是利用wait方法使得线程处于等待状态
 */
public class Demo06 {
    public volatile static  int i = 0 ;
    public static class AddThread extends Thread{
        public void run(){
            for(i = 0 ; i < 1000000; i ++);
        }
    }

    public static void main(String[] args) {
        AddThread at = new AddThread();
        at.start();
        try {
            at.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(i);
    }
}
